/**

 * StarInfoFrameColonyBase.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2011 Roslan Amir. All rights reserved.
 */

package com.roslan.games.moo3d.ui.hud;

import com.ardor3d.extension.ui.UILabel;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.layout.AnchorLayout;
import com.ardor3d.extension.ui.layout.AnchorLayoutData;
import com.ardor3d.extension.ui.util.Alignment;
import com.roslan.games.moo3d.data.Colony;
import com.roslan.games.moo3d.spatial.StarNode;

/**
 * Comments go here.
 * 
 * @author Roslan Amir
 * @version 1.0 - Jan 10, 2011
 */
public abstract class StarInfoFrameColonyBase extends StarInfoFrameExploredBase {

	/**
	 * 
	 */
	protected final UILabel populationValueLabel;

	/**
	 * 
	 */
	protected final UILabel basesValueLabel;

	/**
	 * 
	 */
	protected final UILabel shieldValueLabel;

	/**
	 * Constructor.
	 * 
	 * @param title - the title of the frame
	 */
	public StarInfoFrameColonyBase(String title) {
		super(title);

		final UIPanel panel = new UIPanel();
		panel.setLayout(new AnchorLayout());
		panel.setMargin(HudManager.MARGINS_ZERO);
		panel.setPadding(HudManager.PADDING_2000);
		panel.setBorder(HudManager.SOLID_BORDER_TWO);
		infoPanel.add(panel);

//		final UILabel populationNameLabel = new UILabel("[b]Population:[/b]");
		final UILabel populationNameLabel = new UILabel("Population:");
		populationNameLabel.setStyledText(true);
		populationNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 4, -6));
		panel.add(populationNameLabel);

		populationValueLabel = new UILabel("");
		populationValueLabel.setStyledText(true);
		populationValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 90, -6)); //105
		panel.add(populationValueLabel);

//		final UILabel basesNameLabel = new UILabel("[b]Bases:[/b]");
		final UILabel basesNameLabel = new UILabel("Bases:");
		basesNameLabel.setStyledText(true);
		basesNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 202, -6));
		panel.add(basesNameLabel);

		basesValueLabel = new UILabel("");
		basesValueLabel.setStyledText(true);
		basesValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 278, -6)); // 279
		panel.add(basesValueLabel);

//		final UILabel shieldNameLabel = new UILabel("[b]Shield:[/b]");
		final UILabel shieldNameLabel = new UILabel("Shield:");
		shieldNameLabel.setStyledText(true);
		shieldNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 326, -6));
		panel.add(shieldNameLabel);

		shieldValueLabel = new UILabel("");
		shieldValueLabel.setStyledText(true);
		shieldValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 380, -6)); // 400
		panel.add(shieldValueLabel);
	}

	/**
	 * Update the information to the currently selected Star (or Colony).
	 * 
	 * @param starNode - the Star (or Colony) whose info is to be upadated
	 */
	@Override
	public void update(StarNode starNode) {
		super.update(starNode);

		Colony colony = (Colony) starNode.getStar();
		this.setTitle(starNode.getName() + " (" + starNode.tile.x + ',' + starNode.tile.y + ") (" + colony.owner.getRaceNamePlural() + ')');
//		populationValueLabel.setText("[b][c=#00a]" + colony.population + "[/c][/b]");
//		basesValueLabel.setText("[b][c=#00a]" + colony.bases + "[/c][/b]");
//		shieldValueLabel.setText("[b][c=#00a]" + colony.getShieldClass() + "[/c][/b]");
		populationValueLabel.setText("[c=#00a]" + colony.population + "[/c]");
		basesValueLabel.setText("[c=#00a]" + colony.bases + "[/c]");
		shieldValueLabel.setText("[c=#00a]" + colony.getShieldClass() + "[/c]");
	}

}
